//-----------------------------------------------------------------------------
//クラス名：ClubEdit.java
//所    属：H3A1 04
//名    前：大瀬碩
//説    明：クラブ編集情報確認画面を表示する
//-----------------------------------------------------------------------------
package club;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


//@WebServlet("/ClubEdit")
public class ClubEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
    public ClubEdit() {
        super();
        
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html; charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		HttpSession session = request.getSession(true);
		
		//セッション破棄
		session.removeAttribute("doa");
		session.removeAttribute("poa");
		session.removeAttribute("act");
		
		//入力された編集情報を取得
		String doa = request.getParameter("doa");
		String poa = request.getParameter("poa");
		String act = request.getParameter("act");
		
		//文字変換
		act = htmlspecialchars(act);
		
		session.setAttribute("doa", doa);
		session.setAttribute("poa", poa);
		session.setAttribute("act", act);
		
		RequestDispatcher rd = request.getRequestDispatcher("ClubEditConfirmation.jsp");
		rd.forward(request,response);
	}
	
	public String htmlspecialchars ( String str )
	{
	String ret_val = new String(str);

	String[] escape = {"&", "<", ">", "\"", "\'", "\n", "\t"};
	String[] replace = {"&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "<br>", "&#x0009;"};

	for ( int i=0; i < escape.length; i++ )
	{
	      ret_val = ret_val.replace(escape[i], replace[i]);
	}

	return ret_val;
	}
}
